home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0052_Yes-No Input Prompt.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  791 b   |  36 lines

  1. {
  2. Here is just what you're looking for.  I don't know if you have learned about
  3. "functions" yet, but it's what I'm giving to you.  :-)  A function is just a
  4. procedure which returns a variable (of the type you choose) that is set within
  5. the function before it terminates.  Anyway, here goes...
  6. }
  7.  
  8. function yesno(const s:string):boolean;
  9. var c:char;
  10. begin
  11.   write(s);
  12.   repeat
  13.     asm
  14.       xor ax,ax
  15.       int 16h
  16.       mov dl,al
  17.       mov ax,6520h
  18.       int 21h
  19.       mov c,dl
  20.     end;
  21.   until c in ['Y','N'];
  22.   writeln(c);
  23.   yesno:=(c='Y');
  24. end;
  25.  
  26. And now, here is an example of how you use it.
  27.  
  28. begin
  29.   if yesno('Put "HELLO" on the screen? (y/n) : ') then begin
  30.     writeln('HELLO');
  31.   end else begin
  32.     writeln('Fine, then!  Forget it.');
  33.   end;
  34. end.
  35.  
  36.